<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTableOrder extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('type');
            $table->integer('shop_id')->index();
            $table->integer('user_id')->index();
            $table->string('pay_no', 64)->index();
            $table->integer('link_id')->index();
            $table->string('title');
            $table->integer('price');
            $table->jsonb('detail')->nullable();
            $table->integer('we_chat_pay')->nullable();
            $table->dateTime('we_chat_pay_time')->nullable();
            $table->integer('coupon_pay')->nullable();
            $table->integer('offline_pay')->nullable();
            $table->string('status');
            $table->integer('refund_fee')->nullable();
            $table->integer('referrer_id')->nullable()->index();
            $table->integer('personal_id')->nullable()->index();
            $table->string('cover');
            $table->integer('rebate')->default(0);

            $table->string('mobile')->nullable();
            $table->string('name')->nullable();
            $table->string('address', 1000)->nullable();
            $table->string('deliver_date')->nullable();
            $table->integer('delivery')->nullable();

            $table->integer('is_comment')->default(0);
            $table->integer('is_finish')->default(0);

            $table->jsonb('bill')->nullable();

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
